package logger

import (
	"fmt"
	"gitee.com/zero_clown/tools/tool"
	"go.uber.org/zap"
	"os"
)

var Logger *zap.Logger

func init() {
	_, err := os.Stat("./log")
	if err != nil {
		err = os.Mkdir("./log", os.ModePerm)
		if err != nil {
			fmt.Println("创建日志目录错误")
			panic(err)
		} else {
			fmt.Println("日志目录创建完成")
		}
	}
	logConf := tool.LogConfig{
		Filename:   "./log/log.txt",
		MaxSize:    2,
		MaxBackups: 7,
		Compress:   false,
	}
	Logger = logConf.Logger()
}
